package ui;

import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;

import ui.handlers.CustomerHandler;
import ui.handlers.OrderHandler;

public class CashierHomeScreen extends BaseScreen {

	private JButton placeOrder_btn, createCustomer_btn, viewTrans_btn;
	
	private JFrame mainFrame;
	
	public JButton getPlaceOrderButton()
	{ return placeOrder_btn; }
	
	public JButton getCreateCustomerButton()
	{ return createCustomer_btn; }
	
	public JButton getViewTransButton()
	{ return viewTrans_btn; }
	
	public CashierHomeScreen()
	{
			mainFrame = new JFrame();
			mainFrame.setTitle("Cashier Home Screen");
			mainFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
			mainFrame.setSize(650, 550);
			mainFrame.setLayout(new GridLayout(2, 1));
			
			doTitle();	
			doButtons();
			
			mainFrame.setVisible(true);
	}
	
	private void doTitle()
	{
		String text = "<HTML><FONT SIZE = \"7\">" +
				"Cashier Home Screen</FONT></HTML>";
			JLabel text_lbl = new JLabel(text);
			
			JPanel text_panel = new JPanel();
			text_panel.add(text_lbl);
			text_panel.setBorder(new EmptyBorder(30, 0 , 0, 0));
			
			mainFrame.add(text_panel);
	}
	
	private void doButtons()
	{
		placeOrder_btn = new JButton("Place Order");
		Font btnFont = new Font(placeOrder_btn.getName(),
				placeOrder_btn.getFont().getStyle(), 22);
		placeOrder_btn.setFont(btnFont);
		placeOrder_btn.setBorder(new EmptyBorder(5, 25, 5, 25));
		placeOrder_btn.addActionListener(new OrderHandler(this));
		
		createCustomer_btn = new JButton("Create Customer");
		createCustomer_btn.addActionListener(new CustomerHandler(this));
		createCustomer_btn.setFont(btnFont);
		createCustomer_btn.setBorder(new EmptyBorder(5, 25, 5, 25));
		
		viewTrans_btn = new JButton("View Transactions");
		viewTrans_btn.setFont(btnFont);
		viewTrans_btn.setBorder(new EmptyBorder(5, 25, 5, 25));
		viewTrans_btn.addActionListener(new CustomerHandler(this));
		
		JPanel placeOrder_panel = new JPanel();
		placeOrder_panel.add(placeOrder_btn);
		
		JPanel createCustomer_panel = new JPanel();
		createCustomer_panel.add(createCustomer_btn);
		
		JPanel viewTrans_panel = new JPanel();
		viewTrans_panel.add(viewTrans_btn);
		
		JPanel button_panel = new JPanel();
		button_panel.setLayout(new GridLayout(3, 1));
		
		button_panel.add(placeOrder_panel);
		button_panel.add(createCustomer_panel);
		button_panel.add(viewTrans_panel);
		
		mainFrame.add(button_panel);
	}
}